package com.stu.day06.Record_VS_Class;

import java.util.Objects;

/**
 * @author zy
 * @date 2025/1/27 18:37
 */
public class Point {
    private final int x;
    private final int y;

    // 构造函数
    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }

    // Getter 方法
    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    // 重写 equals 方法
    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null || getClass() != obj.getClass()) return false;
        Point point = (Point) obj;
        return x == point.x && y == point.y;
    }

    // 重写 hashCode 方法
    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }

    // 重写 toString 方法
    @Override
    public String toString() {
        return "Point{x=" + x + ", y=" + y + "}";
    }
}
